<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
</head>
<title>分包合同</title>
<style type="text/css">
    .layui-form-select dl {
        max-height: 150px;
    / / 原值为300，调节高度建议为50的倍数
    }

    .layui-form-label {
        width: 60px;
    }

    .flex {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin-left: 50px !important;
        line-height: 1;
    }

    .flex span {
        line-height: 1;
        margin-right: 10px;
    }
</style>
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="fbht-tab-all">
    <ul class="layui-tab-title">
        <li id="fbhtId" class="layui-this" lay-id="0">合同台账</li>
        <li id="psId" lay-id="1">合同评审</li>
        <li id="bcId" lay-id="2">补充协议</li>
        <li id="qdId" lay-id="3">合同清单</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
        <!-- 融资立项 -->
        <!-- ************************************************* 合同台账 *********************************************************** -->
        <div class="layui-tab-item layui-show">
            <!-- 查询区域  -->
            <div id="fbht-query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proName" placeholder="请输入项目名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">区域公司</label>
                        <div class="layui-input-inline">
                            <select name="hrOrgId">
                                <c:if test="${not empty orgInfoList }">
                                    <c:forEach items="${orgInfoList}" var="orgInfo">
                                        <option value="${orgInfo.id}">${orgInfo.compName }</option>
                                    </c:forEach>
                                </c:if>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">日期</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="fbht-laydate-date" name="date" readonly
                                   placeholder="日期">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <select name="processStatus">
                                <option value="">全部</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-fbht-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-fbht-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                    </div>
                </div>
            </div>
            <!-- 数据表单 -->
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item "
                     style="width: 100% ;background: white;display: flex;margin: 0;padding: 6px 0">
                    <div class="layui-inline flex"><span
                            style="font-size: 35px;color: rgb(22,168,225);margin-top: -5px">○</span>表示：可执行
                    </div>
                    <div class="layui-inline flex"><span style="font-size: 25px;color: rgb(59,177,156)">✓</span>表示：评审通过
                    </div>
                    <div class="layui-inline flex"><span style="font-size: 25px;color: rgb(225,6,6)">ㄨ</span>表示：评审不通过
                    </div>
                    <div class="layui-inline flex"><span style="font-size: 25px;color: rgb(225,93,36)">ニ</span>表示：评审中
                    </div>
                    <div class="layui-inline flex"><span style="font-size: 25px;color: rgb(80,90,110)">／</span>表示：不需要评审
                    </div>
                </div>
                <table id="lay-fbht-create-manage" lay-filter="lay-fbht-create-manage" style="margin-top: 0"></table>
            </div>
        </div>

        <!-- 合同评审 -->
        <!-- ************************************************* 合同评审 *********************************************************** -->
        <div class="layui-tab-item">
            <!-- 查询区域  -->
            <div id="http-query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">项目编码：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proCode" placeholder="请输入项目编码" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proName" placeholder="请输入项目名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">合同名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="contractName" placeholder="请输入合同名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态：</label>
                        <div class="layui-input-inline">
                            <select name="processStatus">
                                <option value="">全部</option>
                                <option value="1">审批中</option>
                                <option value="9">审批完成</option>
                                <option value="10">审批终止</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">签订日期：</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="ps-laydate-dates" name="dates" readonly
                                   placeholder="请选择创建时间">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目负责人：</label>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="projectLeader" placeholder="请输入项目负责人" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">合同总价：</label>
                        <div class="layui-input-inline" style="width:100px">
                            <input type="text" name="sumAmountMin" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width:100px">
                            <input type="text" name="sumAmountMax" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-ps-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-ps-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-ps-new">
                            <i class="layui-icon layui-icon-add-1  layuiadmin-button-btn"></i>新建
                        </button>
                    </div>
                </div>
            </div>
            <!-- 数据表单 -->
            <div class="layui-tab-item layui-show">
                <table id="lay-ps-create-manage" lay-filter="lay-ps-create-manage"></table>
            </div>
        </div>

        <!-- 补充协议 -->
        <!-- ************************************************* 补充协议 *********************************************************** -->
        <div class="layui-tab-item">
            <!-- 查询区域  -->
            <div id="bc-query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">项目编码：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proCode" placeholder="请输入项目编码" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proName" placeholder="请输入项目名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">合同名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="contractName" placeholder="请输入合同名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">状态：</label>
                        <div class="layui-input-inline">
                            <select name="processStatus">
                                <option value="">全部</option>
                                <option value="1">审批中</option>
                                <option value="9">审批完成</option>
                                <option value="10">审批终止</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">签订日期：</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="bc-laydate-dates" name="dates" readonly
                                   placeholder="请选择签订日期">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目负责人：</label>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="projectLeader" placeholder="请输入项目负责人" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-bc-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-bc-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-bc-new">
                            <i class="layui-icon layui-icon-add-1  layuiadmin-button-btn"></i>新建
                        </button>
                    </div>
                </div>
            </div>
            <!-- 数据表单 -->
            <div class="layui-tab-item layui-show">
                <table id="lay-bc-create-manage" lay-filter="lay-bc-create-manage"></table>
            </div>
        </div>

        <!-- 合同清单 -->
        <!-- ************************************************* 合同清单 *********************************************************** -->
        <div class="layui-tab-item">
            <!-- 查询区域  -->
            <div id="qd-query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">项目编码：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proCode" placeholder="请输入项目编码" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="proName" placeholder="请输入项目名称" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目负责人：</label>
                        <div class="layui-input-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="projectLeader" placeholder="请输入项目负责人" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-qd-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-qd-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="lay-qd-new">
                            <i class="layui-icon layui-icon-add-1  layuiadmin-button-btn"></i>录入合同清单
                        </button>
                    </div>
                </div>
            </div>
            <!-- 数据表单 -->
            <div class="layui-tab-item layui-show">
                <table id="lay-qd-create-manage" lay-filter="lay-qd-create-manage"></table>
            </div>
        </div>

    </div>
</div>

<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'transfer', 'laydate', 'element', 'layer'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , element = layui.element
            , laydate = layui.laydate
            , layer = layui.layer;

        loadfbht();

        //选项卡切换监听
        element.on('tab(fbht-tab-all)', function (data) {
            var layId = $(this).attr('lay-id');
            if (layId === "0") {
                loadfbht();
            } else if (layId === "1") {
                loadps();
            } else if (layId === "2") {
                loadbc();
            } else if (layId === "3") {
                loadqd();
            }
        });

        //分包合同台账
        /**************************************** 分包合同台账 **************************************************************/
        function loadfbht() {
            //日期
            laydate.render({
                elem: '#fbht-laydate-date'
                , range: '~'
            });

            // 表单
            table.render({
                elem: '#lay-fbht-create-manage'
                , url: basePath + '/subpackCot/selectByLedger' //请求数据接口
                , cols: [[
                    {field: 'orgAreaName', title: '区域公司', align: 'center'}
                    , {field: 'proName', title: '项目名称', align: 'center'}
                    , {
                        field: 'subpackCotType', title: '合同评审', align: 'center', event: '0', templet: function (d) {
                            var optStr = "";
                            //1=审批中 9=审批完成 10=审批终止
                            if (d.subpackCotType == 1) {
                                optStr += '<span style="font-size: 25px;color: rgb(225,93,36)">ニ</span>';
                            } else if (d.subpackCotType == 9) {
                                optStr += '<span style="font-size: 25px;color: rgb(59,177,156)">✓</span>';
                            } else if (d.subpackCotType == 10) {
                                optStr += '<span style="font-size: 25px;color: rgb(225,6,6)">ㄨ</span>';
                            } else if (d.subpackCotId) {
                                optStr += ' <span style="font-size: 35px;color: rgb(22,168,225);margin-top: -5px">○</span>';
                            }
                            return optStr;
                        }
                    }
                    , {
                        field: '', title: '用章', align: 'center', event: '1', templet: function (d) {

                        }
                    }
                    , {
                        field: '', title: '签字', align: 'center', event: '2', templet: function (d) {

                        }
                    }
                    , {
                        field: 'subpackSuppleCount', title: '补充协议', align: 'center'

                    }
                    , {
                        field: 'subpackEntryType', title: '合同清单', align: 'center', event: '4', templet: function (d) {
                            var optStr = "";
                            //1=审批中 9=审批完成 10=审批终止
                            if (d.subpackEntryType == 1) {
                                optStr += '<span style="font-size: 25px;color: rgb(225,93,36)">ニ</span>';
                            } else if (d.subpackEntryType == 9) {
                                optStr += '<span style="font-size: 25px;color: rgb(59,177,156)">✓</span>';
                            } else if (d.subpackEntryType == 10) {
                                optStr += '<span style="font-size: 25px;color: rgb(225,6,6)">ㄨ</span>';
                            } else if (d.subpackEntryId) {
                                optStr += ' <span style="font-size: 35px;color: rgb(22,168,225);margin-top: -5px">○</span>';
                            }
                            return optStr;
                        }
                    }
                ]]
                , page: true
                , limit: 10
            });

            //监听搜索
            form.on('submit(lay-fbht-search)', function (data) {
                table.reload('lay-fbht-create-manage', {
                    page: {curr: 1},
                    where: trimData(data)
                });
            });
            //重置清空
            form.on('submit(lay-fbht-back-reset)', function (data) {
                reset_form('fbht-query-form');
                //额外处理select
                $("#query-form-state").val('');
                form.render();
            });

            // 监听操作列
            table.on('tool(lay-fbht-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看详情
                    parent.layui.index.openTabsPage(basePath + '/proTrack/toDealOrDetail?proCode=' + data.proCode, '项目跟踪 > 详情');
                } else if (obj.event === 'copy') {//复制单据
                    parent.layui.index.openTabsPage(basePath + '/collectProject/toCopy?id=' + data.id, '项目信息收集 > 复制单据');
                } else if (obj.event === 'del') {
                    layer.confirm('确定要删除？', {icon: 3, title: '提示'}, function (index) {
                        $.ajax({
                            type: 'post',
                            url: basePath + '/flowProcess/logicDel',
                            data: {
                                "processId": data.processId
                            },//数据，这里使用的是Json格式进行传输
                            success: function (result) {
                                if (result) {
                                    table.reload('lay-fbht-create-manage'); //数据刷新
                                    layer.close(index); //关闭弹层
                                } else {
                                    layer.msg('数据通信异常~', {icon: 0});
                                }
                            }
                        });
                    })
                } else if (obj.event === '0') {
                    parent.layui.index.openTabsPage(basePath + '/collectProject/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '项目信息收集 > 详情');
                } else if (obj.event === '1') {
                    if (data.prepareProType) {
                        parent.layui.index.openTabsPage(basePath + '/preProject/toDealOrDetail?id=' + data.prepareProId + '&proCode=' + data.proCode, '预立项 > 详情');
                    }
                } else if (obj.event === '2') {
                    if (data.projectType) {
                        parent.layui.index.openTabsPage(basePath + '/setupPro/toDealOrDetail?id=' + data.projectId + '&proCode=' + data.proCode, '立项 > 详情');
                    }
                } else if (obj.event === '3') {
                    if (data.marketingType) {
                        parent.layui.index.openTabsPage(basePath + '/proSell/toDealOrDetail?proCode=' + data.proCode + '&id=' + data.marketingId, '营销策划 > 详情');

                    }
                }
            });
        }

        /******************************************** 合同评审 *********************************************************/
        function loadps() {
            //日期
            laydate.render({
                elem: '#ps-laydate-dates'
                , range: '~'
            });
            // 表单
            table.render({
                elem: '#lay-ps-create-manage'
                , url: basePath + '/subpackCot/queryDataByCondition' //请求数据接口
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'proCode', title: '项目编码', width: 145}
                    , {field: 'proName', title: '项目名称'}
                    , {field: 'contractName', title: '合同名称', align: 'center'}
                    , {
                        field: 'signDate', title: '签订日期', width: 160, templet: function (d) {
                            return layui.util.toDateString(d.signDate, "yyyy-MM-dd");
                        }
                    }
                    , {
                        field: 'sumTotal', title: '合同总价', width: 150, templet: function (d) {
                            return formatCurrency(d.sumTotal);
                        }
                    }
                    , {field: 'projectLeader', title: '项目负责人', width: 100}
                    , {
                        field: 'processStatus', title: '单据状态', width: 155, templet: function (d) {
                            var status = '';
                            if (d.processStatus == '1') {
                                status = '审批中'
                            } else if (d.processStatus == '9') {
                                status = '审批完成'
                            } else if (d.processStatus == '10') {
                                status = '审批终止'
                            }
                            return status
                        }
                    }
                    , {
                        title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                            var optStr = "";
                            optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                            return optStr;
                        }
                    }
                ]]
                , page: true
                , limit: 10
            });

            //监听新建
            form.on('submit(lay-ps-new)', function (data) {
                parent.layui.index.openTabsPage(basePath + '/subpackCot/toDealOrDetail', '合同评审 > 详情');
            });

            //监听搜索
            form.on('submit(lay-ps-search)', function (data) {
                table.reload('lay-ps-create-manage', {
                    page: {curr: 1},
                    where: trimData(data)
                });
            });
            //重置清空
            form.on('submit(lay-ps-back-reset)', function (data) {
                reset_form('ps-query-form');
                //额外处理select
                $("#query-form-state").val('');
                form.render();
            });


            // 监听操作列
            table.on('tool(lay-ps-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看详情
                    parent.layui.index.openTabsPage(basePath + '/subpackCot/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '合同评审 > 详情');
                } else if (obj.event === 'copy') {//复制单据
                    parent.layui.index.openTabsPage(basePath + '/subpackCot/toCopy?id=' + data.id, '合同评审 > 复制单据');
                } else if (obj.event === 'del') {
                    layer.confirm('确定要删除？', {icon: 3, title: '提示'}, function (index) {
                        $.ajax({
                            type: 'post',
                            url: basePath + '/flowProcess/logicDel',
                            data: {
                                "processId": data.processId
                            },//数据，这里使用的是Json格式进行传输
                            success: function (result) {
                                if (result) {
                                    table.reload('lay-ps-create-manage'); //数据刷新
                                    layer.close(index); //关闭弹层
                                } else {
                                    layer.msg('数据通信异常~', {icon: 0});
                                }
                            }
                        });
                    })
                }
            });
        }

        //补充协议
        /*************************************************** 补充协议 **********************************************************/
        function loadbc() {
            //日期
            laydate.render({
                elem: '#bc-laydate-dates'
                , range: '~'
            });

            // 表单
            table.render({
                elem: '#lay-bc-create-manage'
                ,
                url: basePath + '/subpackSupple/queryDataByCondition' //请求数据接口
                ,
                cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'proCode', title: '项目编码', width: 145}
                    , {field: 'proName', title: '项目名称'}
                    , {field: 'contractName', title: '补充协议名称', align: 'center'}
                    , {
                        field: 'signDate', title: '补充协议签订日期', width: 160, templet: function (d) {
                            return layui.util.toDateString(d.signDate, "yyyy-MM-dd");
                        }
                    }
                    , {field: 'contractYearTime', title: '总合同期(年)', width: 160}
                    , {field: 'projectLeader', title: '项目负责人', width: 100}
                    , {
                        field: 'processStatus', title: '单据状态', width: 155, templet: function (d) {
                            var status = '';
                            if (d.processStatus == '1') {
                                status = '审批中'
                            } else if (d.processStatus == '9') {
                                status = '审批完成'
                            } else if (d.processStatus == '10') {
                                status = '审批终止'
                            }
                            return status
                        }
                    }
                    , {
                        title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                            var optStr = "";
                            optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                            return optStr;
                        }
                    }
                ]]
                ,
                page: true
                ,
                limit: 10
            });

            //监听搜索
            form.on('submit(lay-bc-search)', function (data) {
                table.reload('lay-bc-create-manage', {
                    page: {curr: 1},
                    where: trimData(data)
                });
            });
            //重置清空
            form.on('submit(lay-bc-back-reset)', function (data) {
                reset_form('bc-query-form');
                //额外处理select
                $("#query-form-state").val('');
                form.render();
            });
            form.on('submit(lay-bc-new)', function (data) {
                parent.layui.index.openTabsPage(basePath + '/subpackSupple/toDealOrDetail', '补充协议 > 详情');
            });

            // 监听操作列
            table.on('tool(lay-bc-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看详情
                    parent.layui.index.openTabsPage(basePath + '/subpackSupple/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '补充协议 > 详情');
                } else if (obj.event === 'copy') {//复制单据
                    parent.layui.index.openTabsPage(basePath + '/subpackSupple/toCopy?id=' + data.id, '补充协议 > 复制单据');
                } else if (obj.event === 'del') {
                    layer.confirm('确定要删除？', {icon: 3, title: '提示'}, function (index) {
                        $.ajax({
                            type: 'post',
                            url: basePath + '/flowProcess/logicDel',
                            data: {
                                "processId": data.processId
                            },//数据，这里使用的是Json格式进行传输
                            success: function (result) {
                                if (result) {
                                    table.reload('lay-bc-create-manage'); //数据刷新
                                    layer.close(index); //关闭弹层
                                } else {
                                    layer.msg('数据通信异常~', {icon: 0});
                                }
                            }
                        });
                    })
                }
            });
        }

        //合同清单
        /*************************************************** 合同清单 **********************************************************/
        function loadqd() {
            //日期
            laydate.render({
                elem: '#qd-laydate-dates'
                , range: '~'
            });

            // 表单
            table.render({
                elem: '#lay-qd-create-manage'
                ,
                url: basePath + '/subpackEntry/queryDataByCondition' //请求数据接口
                ,
                cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'proCode', title: '项目编码', width: 145}
                    , {field: 'proName', title: '项目名称'}
                    , {field: 'contractName', title: '合同名称', align: 'center'}
                    , {field: 'contType', title: '承包模式', align: 'center'}
                    , {field: 'contractYearTime', title: '总合同期(年)', width: 160}
                    , {field: 'projectLeader', title: '项目负责人', width: 100}
                    , {
                        title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                            var optStr = "";
                            optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                            return optStr;
                        }
                    }
                ]]
                ,
                page: true
                ,
                limit: 10
            });

            //监听新建
            form.on('submit(lay-qd-new)', function (data) {
                parent.layui.index.openTabsPage(basePath + '/contractNeg/toDealOrDetail', '合同谈判 > 详情');
            });

            //监听搜索
            form.on('submit(lay-qd-search)', function (data) {
                table.reload('lay-qd-create-manage', {
                    page: {curr: 1},
                    where: trimData(data)
                });
            });
            //重置清空
            form.on('submit(lay-qd-back-reset)', function (data) {
                reset_form('qd-query-form');
                //额外处理select
                $("#query-form-state").val('');
                form.render();
            });

            // 监听操作列
            table.on('tool(lay-qd-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看详情
                    parent.layui.index.openTabsPage(basePath + '/contractBpaReview/toDealOrDetail?id=' + data.id + '&proCode=' + data.proCode, '预立项 > 详情');
                } else if (obj.event === 'copy') {//复制单据
                    parent.layui.index.openTabsPage(basePath + '/contractBpaReview/toCopy?id=' + data.id, '项目信息收集 > 复制单据');
                } else if (obj.event === 'del') {
                    layer.confirm('确定要删除？', {icon: 3, title: '提示'}, function (index) {
                        $.ajax({
                            type: 'post',
                            url: basePath + '/flowProcess/logicDel',
                            data: {
                                "processId": data.processId
                            },//数据，这里使用的是Json格式进行传输
                            success: function (result) {
                                if (result) {
                                    table.reload('lay-bc-create-manage'); //数据刷新
                                    layer.close(index); //关闭弹层
                                } else {
                                    layer.msg('数据通信异常~', {icon: 0});
                                }
                            }
                        });
                    })
                }
            });
        }

        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</body>
</html>

